package com.xiaohongshu.kafkademo.lambda;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.IntBinaryOperator;
import java.util.function.IntPredicate;

public class t1 {
    private static AtomicInteger p1 = new AtomicInteger(1);
    public static void main(String[] args) {
//        Thread thread1 = new Thread(
//                ()-> {
//                        for (int i = 0; i < 10; i++) {
//                            System.out.printf("第%d次取数%d\n",i+1,p1.getAndAdd(1));
//                        }
//                    }
//
//        );
//        thread1.start();
//          calculateNum((left, right) -> left + right);
        printNum(value->
             value % 2 == 0
        );
    }


    public static int calculateNum(IntBinaryOperator op) {
        int a = 10;
        int b = 20;
        return op.applyAsInt(a, b);
    }

    static void printNum(IntPredicate p) {
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i : a) {
            if (p.test(i)) {
                System.out.println(i);
            }
        }
    }
}
